package com.zpark.pojo;

import com.zpark.dao.CustomAgeValidator;
import lombok.Data;
import org.hibernate.validator.constraints.Length;


import javax.validation.Valid;
import javax.validation.constraints.*;

@Data
public class User {
    @NotBlank(message = "姓名不允许为空")
    @Length(min = 2,max = 10,message = "姓名长度错误，长度长度2-10！")
    private String name;

//    @NotNull(message = "年龄不能为空")
//    @Min(value = 18,message = "年齡最小不能小于18")
    @CustomAgeValidator
    private int age;

    @NotBlank(message = "地址不能为空")
    private String address;

    @Pattern(regexp = "^1(3[0-9]|5[012356789]|7[1235678]|8[0-9])\\d{8}$", message ="手机号格式错误")
    private String phone;

    @Email(message = "邮箱格式错误")
    private String email;

    @NotNull
    @Valid
    //JavaBean 对象级联校验
    private UserDetail userDetail;
    //省略get、set方法
}